package com.kfm.mybatis.clone;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import lombok.Getter;
import lombok.Setter;

import java.io.*;

@Getter
@Setter
public class Account implements Serializable {

    private Integer id;

    private String username;

    private String password;

    private User user;

    @Override
    public String toString(){
        return super.toString() + "(id=" + this.getId() + ", username=" + this.getUsername() + ", password=" + this.getPassword() + ", user=" + this.getUser() + ")";
    }

}

@Getter
@Setter
class User implements Serializable {

    private Integer uId;

    private String name;

    public String toString() {
        Integer var10000 = this.getUId();
        return super.toString() + "(uId=" + var10000 + ", name=" + this.getName() + ")";
    }

}

class Demo {


    public static void main(String[] args) {
        Account account = new Account();
        account.setId(1);
        account.setUsername("kfm");
        account.setPassword("123456");
        User user = new User();
        user.setUId(2);
        user.setName("开发喵");
        account.setUser(user);
        System.out.println(account);


        String s = JSON.toJSONString(account);
        System.out.println(s);

        Account account1 = JSON.parseObject(s, Account.class);
        System.out.println(account1);

    }
}
